/*
 * @Author: YYJ
 * @Date: 2023-12-16 14:40:39
 * @Description: 
 * @FilePath: \lgd-admin\src\services\study\catalog\index.tsx
 */
import { request } from '@umijs/max';

export interface StudyCatalogParams {
  catalogId?: number;
  type?: string;
  status?: string;
  current?: number;
  pageSize?: number;
}

export interface StudyCatalogItem {
  id?: number;
  parentid?: number;
  name?: string;
  sortNum?: number;
  children?: [];
  optType: 'add' | 'edit' | 'addSub';
}

/** 查询学习目录列表 POST /admin/studyCatalog/queryCatalogMenu */
export async function queryCatalogTree() {
  return request<API.LgdTable>('/admin/studyCatalog/queryCatalogTree', {
    method: 'POST',
  });
}

/** 查询学习目录列表 POST /admin/studyCatalog/queryList */
export async function queryTreeList(body: StudyCatalogParams) {
  return request<API.LgdTable>('/admin/studyCatalog/queryTreeList', {
    method: 'POST',
    data: body
  });
}

/** 查询学习目录列表 POST /admin/studyCatalog/addUpdate */
export async function addUpdate(body: StudyCatalogItem) {
  return request<API.LgdResult>('/admin/studyCatalog/addUpdate', {
    method: 'POST',
    data: body
  });
}

export async function remove(id?: number) {
  return request('/admin/studyCatalog/remove?id=' + id, {
    method: 'POST',
  });
}